//初始化
var form;
var $;
var laydate;
var table;
layui.use(['form','laydate','jquery','table'],function(){
    form = layui.form;
    $ = layui.$;
    laydate=layui.laydate;
    table=layui.table;



    fun();
    function fun() {

        var idArray = window.location.search.split("?");
        var userId = idArray[1];
        $.ajax({
            url:"/personnel/selUserVideo2",
            type:"post",
            dataType:"json",
            data:{"userId":userId},
            success:function(item) {
                courseTable(item.data);
            }
        });
    }

    function courseTable(data) {
        table.render({
            elem:"#table_id",
            data:data,
            limit:6,
            toolbar:'#toolbarDemo',
            page:true,
            cols:[[
                {type:'checkbox',align:'center',width:40},
                {title:'序号',width:60,align:'center',templet:function(data){
                        return data.LAY_INDEX;
                    }},
                {field:'url',title:'课程图片',align:'center',width:130,templet:function(data){
                        if(data.url!=null){
                            return "<img src='"+data.url+"'height='100'>";
                        }else{
                            return "<span>无图片</span>"
                        }

                    }},
                {field:'course_name',title:'课程名称',align:'center'},
                {field:'course_nprice',title:'价格',align:'center',templet:function(data){
                        return "$"+data.course_nprice+"";
                    }},
                {field:'name',title:'分类',align:'center'},
                {field:'collect_num',title:'收藏量',align:'center'},
                {field:'like_num',title:'点赞量',align:'center'},
                {field:'sale_num',title:'销量',align:'center'}
            ]]
        });
    }
});